import Vue from "vue";
import VueRouter from "vue-router";


//路由懒加载
const Login = () => import('@/views/Login')
const Home=()=>import("../views/Home");
const Users=()=>import("../views/Users");
const Categories=()=>import("../views/Categories");
const Goods=()=>import("../views/Goods");
const Orders=()=>import("../views/Orders");
const Params=()=>import("../views/Params");
const Reports=()=>import("../views/Reports");
const Rights=()=>import("../views/Rights");
const Roles=()=>import("../views/Roles");
const Welcome=()=>import("../views/Welcome");

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect:'/login',
  },
  {
    path: '/login',
    name: 'login',
    component:Login
  },
  {
    path: '/home',
    name: 'home',
    redirect:'/welcome',
    meta: { auth: true },
    component: Home,
    children: [
      {path:'/welcome',component:Welcome},
      {path:'/users',component:Users},
      {path:'/categories',component:Categories},
      {path:'/goods',component:Goods},
      {path:'/orders',component:Orders},
      {path:'/params',component:Params},
      {path:'/reports',component:Reports},
      {path:'/rights',component:Rights},
      {path:'/roles',component:Roles},

    ]
  }
];

const router = new VueRouter({
  routes,
});

export default router;
